package com.kushuigu.service.impl;

import com.kushuigu.dao.BookDao;
import com.kushuigu.dao.UserDao;
import com.kushuigu.service.BookService;
import lombok.Setter;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;

public class BookServiceImpl implements BookService, InitializingBean,
        DisposableBean {
    @Setter
    private BookDao bookDao;
    @Setter
    private UserDao userDao;
    @Setter
    private String dbName;
    @Setter
    private int connectNum;

    public BookServiceImpl(BookDao bookDao, UserDao userDao, String dbName, int connectNum) {
        this.bookDao = bookDao;
        this.userDao = userDao;
        this.dbName = dbName;
        this.connectNum = connectNum;
    }

    @Override
    public void save() {
        System.out.println("book service save.");
        bookDao.save();
        userDao.save();
        System.out.println(dbName+connectNum);
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("service destroy.");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("service init.");
    }
}
